from DataTools import datatool
from strategy_mode import dataLoader


def LoadingLoop(
    code,
    pre="5",
    printLens=60,
    Cutting_start_date="2018-11-10",
    dirDic={
        "Main": "D:/StockDatas/",
        "basic": "basic/",
        "daily": "163_Daily_Bar/",
        "report": "Reports/",
        "temp": "temp/",
        "ticker": "History_ticker/",
        "mins": "History_mins/",
    },
):
    endday = datatool.getTradedayinfo(
        MainPath=dirDic["Main"], subPath=dirDic["basic"], mode="LastOpenDay"
    )
    StockDataDic = datatool.getCodeAndDetail(
        MainPath=dirDic["Main"], subPath=dirDic["basic"]
    )
    stock_details = StockDataDic[code]

    df = dataLoader.LoadDF(
        code,
        stock_details,
        pre=pre,
        startdate=Cutting_start_date,
        endday=endday,
        dirDic=dirDic,
        printLens=printLens,
    )
    # print("loaded".center(printLens, " "))
    return stock_details, df